home *** CD-ROM | disk | FTP | other *** search
/ Merciful 1 / Merciful - Disc 1.iso / software / i / image_fx / imagefxv1.5c.dms / imagefxv1.5c.adf / MAGIC / include / magic / magic.h < prev   
C/C++ Source or Header  |  1993-07-15  |  6KB  |  213 lines

  1. /*
  2.  * MAGIC - structures and definitions.
  3.  *
  4.  * Developed by Thomas Krehbiel
  5.  * Nova Design, Inc.
  6.  *
  7.  * December, 1992
  8.  *
  9.  */
  10.  
  11. #ifndef MAGIC_MAGIC_H
  12.  
  13.  
  14. #ifndef EXEC_TYPES_H
  15. #include <exec/types.h>
  16. #endif
  17.  
  18. #ifndef EXEC_NODES_H
  19. #include <exec/nodes.h>
  20. #endif
  21.  
  22. #ifndef EXEC_LISTS_H
  23. #include <exec/lists.h>
  24. #endif
  25.  
  26. #ifndef EXEC_LIBRARIES_H
  27. #include <exec/libraries.h>
  28. #endif
  29.  
  30. #ifndef EXEC_SEMAPHORES_H
  31. #include <exec/semaphores.h>
  32. #endif
  33.  
  34. #ifndef UTILITY_TAGITEM_H
  35. #include <utility/tagitem.h>
  36. #endif
  37.  
  38.  
  39. #define MAGIC_NAME         "magic.library"
  40.  
  41.  
  42. /*
  43.  * Library base
  44.  */
  45. struct MagicBase {
  46.    struct Library          LibNode;
  47.    struct Task            *Server;           /* Server task */
  48.    struct SignalSemaphore  Lock;             /* Lock on PI list */
  49.    struct List             MagicImageList;   /* List of public images */
  50.    struct MagicImage      *DefaultImage;     /* "Active" image */
  51.    LONG                    Counter;          /* Name counter */
  52. };
  53.  
  54.  
  55. /*
  56.  * MAGIC image definition
  57.  */
  58. struct MagicImage {
  59.  
  60.    struct Node             Node;
  61.  
  62.    char                    Name[128];     /* Image name for reference */
  63.  
  64.    ULONG                   Flags;         /* Various flags - see below */
  65.    LONG                    Width;         /* Pixel width */
  66.    LONG                    Height;        /* Pixel height */
  67.    LONG                    Depth;         /* 8-bit planes (generally
  68.                                              1 for greyscale and 3
  69.                                              for color) */
  70.  
  71.    WORD                    AspectX,       /* Horizontal pixel aspect */
  72.                            AspectY;       /* Vertical pixel aspect */
  73.  
  74.    WORD                    DPIX,          /* Horizontal dpi */
  75.                            DPIY;          /* Vertical dpi */
  76.  
  77.    char                   *OwnerName;     /* Name of image's owner */
  78.  
  79.    LONG                    Reserved[7];
  80.  
  81.    UBYTE                  *Red,           /* Direct pointers to RGB planes */
  82.                           *Green,         /* and alpha channel.  If these are */
  83.                           *Blue,          /* NULL, a translation function */
  84.                           *Alpha;         /* must be used instead */
  85.  
  86.    APTR                    ImageData;     /* Image data handle - only
  87.                                              the owner of an image
  88.                                              can mess with this. */
  89.  
  90.    /*
  91.     * The following fields are PRIVATE!  Do not touch.
  92.     */
  93.  
  94.    struct SignalSemaphore  Lock;          /* Semaphore for obtaining
  95.                                              an exclusive write-lock on
  96.                                              the image.  To prevent two
  97.                                              tasks from writing to the
  98.                                              image at the same time. */
  99.    struct Task            *Owner;         /* Task owning this image. */
  100.    struct MsgPort         *OwnerPort;     /* Owner's message port. */
  101.    struct List             OpenList;      /* List of tasks that currently
  102.                                              have access to this
  103.                                              image. */
  104.    LONG                    OpenCount;     /* Number of tasks (besides
  105.                                              the owner) that currently
  106.                                              have this image open. */
  107.  
  108.    int                   (*GetData)(struct PublicImage *, LONG, LONG, Tag *);
  109.    int                   (*PutData)(struct PublicImage *, LONG, LONG, Tag *);
  110.  
  111. };
  112.  
  113. /*
  114.  * MagicHandle - returned by OpenMagicImage()
  115.  */
  116. struct MagicHandle {
  117.    struct Node             Node;
  118.    UWORD                   Flags;         /* reserved */
  119.    struct MagicImage      *Object;        /* Image that is opened */
  120.    struct MsgPort         *Port;          /* Port to send messages
  121.                                              about this image. */
  122. };
  123.  
  124.  
  125. /* Tags passed to AllocMagicImage(): */
  126. enum AMI_Tags {
  127.    AMI_Width = TAG_USER,
  128.    AMI_Height,
  129.    AMI_Depth,
  130.    AMI_Name,
  131.    AMI_ImageData,
  132.    AMI_GetDataCode,
  133.    AMI_PutDataCode,
  134.    AMI_MsgPort,
  135.    AMI_Red,
  136.    AMI_Green,
  137.    AMI_Blue,
  138.    AMI_Alpha,
  139.    AMI_AspectX,
  140.    AMI_AspectY,
  141.    AMI_DPIX,
  142.    AMI_DPIY,
  143.    AMI_OwnerName
  144. };
  145. #define AMI_Grey  AMI_Red
  146.  
  147. /* Tags passed to OpenMagicImage(): */
  148. enum OMI_Tags {
  149.    OMI_MsgPort = TAG_USER,    /* opener's should use this */
  150.    OMI_OwnerPort,             /* owner's should use this instead */
  151. };
  152.  
  153. /* Tags passed to GetMagicImageData() and PutMagicImageData(): */
  154. enum GMI_Tags {
  155.    GMI_Red = TAG_USER,  /* red bytes */
  156.    GMI_Green,           /* green bytes */
  157.    GMI_Blue,            /* blue bytes */
  158.    GMI_RGB,             /* RGB bytes (requires 3 times storage!) */
  159.    GMI_ARGB,            /* ARGB bytes (requires 4 times storage!) */
  160.    GMI_Alpha,           /* alpha channel bytes */
  161.    GMI_Mask             /* (reserved) */
  162. };
  163. #define GMI_Grey  GMI_Red
  164.  
  165. /* Lock types passed to [Attempt]LockMagicImage(): */
  166. #define LMI_Read           1
  167. #define LMI_Write          2
  168.  
  169. /* Tags passed to PickMagicImageA(): */
  170. enum PMI_Tags {
  171.    PMI_IncludeName = TAG_USER,
  172.    PMI_ExcludeName,
  173.    PMI_IncludeOwner,
  174.    PMI_ExcludeOwner,
  175.    PMI_MinWidth,
  176.    PMI_MinHeight,
  177.    PMI_MinDepth,
  178.    PMI_MaxWidth,
  179.    PMI_MaxHeight,
  180.    PMI_MaxDepth,
  181.    PMI_ShowSize,
  182.    PMI_ShowOwner,
  183.    PMI_All,
  184. };
  185.  
  186. /*
  187.  * Messages sent to OwnerPort, and/or to each opener.
  188.  */
  189. struct MagicMessage {
  190.    struct Message          Msg;           /* Exec message */
  191.    struct MagicImage      *Object;        /* Object of this message */
  192.    LONG                    Action;        /* What to do */
  193.    LONG                    Args[8];       /* Up to 8 parameters */
  194.    LONG                    Result;        /* Result code */
  195.    struct Task            *Server;        /* Server task - do not touch */
  196. };
  197.  
  198. /* Message Actions */
  199. enum Act_Tags {
  200.    MMSG_KILLSERVER = 0,                   /* Server Private */
  201.    MMSG_REDRAW,                           /* Redraw image */
  202.    MMSG_TOFRONT,                          /* Bring interface to front */
  203.    MMSG_UPDATE,                           /* Update size */
  204.    MMSG_SAVEUNDO,                         /* Save a copy of buffer */
  205.    MMSG_RESTOREUNDO,                      /* Restore undo buffer */
  206.    MMSG_CLOSE,                            /* Closing an image */
  207. };
  208.  
  209.  
  210.  
  211. #define MAGIC_MAGIC_H
  212. #endif
  213.